package com.xuelang.pipeline.artifact.entry.nexus3v1;

import com.xuelang.pipeline.artifact.app.nexus3v1.SecurityRoleService;
import com.xuelang.pipeline.artifact.app.nexus3v1.request.CreateRoleRequest;
import com.xuelang.pipeline.artifact.app.nexus3v1.response.CreateRoleResponse;
import com.xuelang.pipeline.artifact.app.nexus3v1.xo.ApiResponseXO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

/**
 * Nexus3V1 角色管理原生接口web服务
 *
 * @author xiwen.zxg
 * @since 2024/7/9
 */
@RestController
@RequestMapping("/security/role")
public class SecurityRoleController {

    @Autowired
    SecurityRoleService securityRoleService;

    /**
     * 新增角色
     *
     * @param createRoleRequest
     * @return
     */
    @PostMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResponseXO<CreateRoleResponse> createRole(@RequestBody @Valid CreateRoleRequest createRoleRequest) {
        return securityRoleService.createRole(createRoleRequest);
    }

    /**
     * 删除角色
     *
     * @param id
     * @return
     */
    @DeleteMapping(value = "/{id}", produces = "application/json;charset=utf-8")
    ApiResponseXO<Void> deleteRole(@PathVariable("id") String id) {
        return securityRoleService.deleteRole(id);
    }



}
